{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第五次练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 请务必交到exer5文件夹下，**谢绝交到master下**\n",
    "+ 请不要改动任何文件，拜托\n",
    "+ 请在11月7日前提交。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请写一下姓名和学号：\n",
    "+ 姓名 刘鑫 \n",
    "+ 学号 0165221"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目一、贫困户模型\n",
    "+ 创建一个类，包含贫困户的义务教育保障、住房安全、饮水安全、肉蛋奶豆的四个属性\n",
    "+ 包含一个是否贫困的预测，如果四个属性有两个以上没有保障（>2)则输出为贫困户\n",
    "+ 对贫困户，采取相应措施（输入参数）对其进行帮扶，使其脱贫\n",
    "+ 至少生成三个实例\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "you are a poor\n",
      "you need Housing subsidies\n",
      "you need Education funding\n",
      "you need some pure water\n",
      "you are a poor\n",
      "you need Education funding\n",
      "you need some pure water\n",
      "you need some of the nutrition\n",
      "you are a not poor\n"
     ]
    }
   ],
   "source": [
    "class Secures():\n",
    "    def __init__(self, zhufang, jiaoyu, anquanyinshui, roudannai):  ## 需要定义传递的值\n",
    "        self.zhufang = zhufang\n",
    "        self.jiaoyu = jiaoyu\n",
    "        self.anquanyinshui = anquanyinshui\n",
    "        self.roudannai = roudannai\n",
    "\n",
    "    def pingpanbiaozhun(self, house,education,purewater, roudannai):#建立评判标准\n",
    "        if house == \"have\":\n",
    "            s.zhufang =0\n",
    "        else:\n",
    "            s.zhufang =1\n",
    "        if education==\"have\":\n",
    "            s.jiaoyu=0\n",
    "        else:\n",
    "            s.jiaoyu =1\n",
    "        if purewater==\"have\":\n",
    "            s.anquanyinshui=0\n",
    "        else:\n",
    "            s.anquanyinshui =1\n",
    "        if  roudannai==\"have\" :\n",
    "            s.roudannai=0\n",
    "        else:\n",
    "            s.roudannai=1\n",
    "        sum=s.zhufang+s.jiaoyu+s.anquanyinshui+s.roudannai\n",
    "        if sum>=2:\n",
    "            print(\"you are a poor\")\n",
    "        else: \n",
    "            print(\"you are a not poor\")\n",
    "        if sum>=2  and s.zhufang==1:#建立对贫困人的帮扶\n",
    "            print(\"you need Housing subsidies\")\n",
    "        if sum>=2  and s.jiaoyu==1:\n",
    "            print(\"you need Education funding\")\n",
    "        if sum>=2  and s.anquanyinshui==1:\n",
    "            print(\"you need some pure water\")\n",
    "        if sum>=2  and s.roudannai==1:\n",
    "            print(\"you need some of the nutrition\")\n",
    "s=Secures(1,1,1,1)\n",
    "s.pingpanbiaozhun(\"no\",\"no\",\"no\",\"have\")\n",
    "s.pingpanbiaozhun(\"have\",\"no\",\"no\",\"no\")\n",
    "s.pingpanbiaozhun(\"have\",\"have\",\"have\",\"have\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目二: 学生信息\n",
    "+ 创建一个类，包含姓名、分数、睡眠时间三个属性\n",
    "+ 包含一个胖瘦的预测，如果分数>90，且睡眠时间少于6小时，输出“BMI可能偏大”，否则输出“体重正常”\n",
    "+ 为使得标准（90分、6小时）可以调整，标准应设为输入的参数\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "体重正常\n",
      "BMI可能偏大\n",
      "BMI可能偏大\n"
     ]
    }
   ],
   "source": [
    "class Student_information():\n",
    "    def __init__(self,name,score,sleep_time):\n",
    "        self.name=name\n",
    "        self.score=score\n",
    "        self.sleep_time=sleep_time\n",
    "    def prediction(self,c1,c2):\n",
    "        if self.score>c1 and self.sleep_time<c2:\n",
    "            return \"BMI可能偏大\"\n",
    "        else:\n",
    "            return \"体重正常\"\n",
    "a=Student_information(\"刘鑫\",80,5)\n",
    "print(a.prediction(90,6))\n",
    "b=Student_information(\"占晓洋\",100,5)\n",
    "print(b.prediction(90,6))\n",
    "c=Student_information (\"王文韬\",90,5)\n",
    "print(c.prediction(80,6))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目三：“跑步社”成员类\n",
    "+ 创建一个“跑步社”成员类，以学生信息类为父类\n",
    "+ 添加一个属性为跑步\n",
    "+ 如果跑步时间大于30分钟，如果之前预测为“BMI可能偏大”，则输出为“趋向正常”\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "体重正常\n",
      "BMI可能偏大\n",
      "体重正常\n"
     ]
    }
   ],
   "source": [
    "class Running_man(Student_information):\n",
    "    def __init__(self,name,score,sleep_time,run_time):\n",
    "        super().__init__(name,score,sleep_time)## 通过super函数声明继承了父类的属性\n",
    "        self.run_time=run_time\n",
    "        def prediction(self,c1,c2):\n",
    "            if self.score>c1 and self.sleep_time<c2 and self.run_time>30:\n",
    "                return \"趋向正常\"\n",
    "            elif self.score>c1 and self.sleep_time<c2:\n",
    "                return \"BMI可能偏大\"\n",
    "            else:\n",
    "                return \"体重正常\"\n",
    "a=Running_man(\"刘鑫\",80,5,25)\n",
    "print(a.prediction(90,6))\n",
    "b=Running_man(\"占晓洋\",100,5,40)\n",
    "print(b.prediction(90,6))\n",
    "c=Running_man(\"王文韬\",90,5,40)\n",
    "print(c.prediction(90,6))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
